package org.jeecg.modules.controller.doctor;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.modules.doctor.entity.DoctorRegisterHospital;
import org.jeecg.common.modules.doctor.service.IDoctorRegisterHospitalService;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @Description: doctor_register_hospital
* @Author: jeecg-boot
* @Date:   2020-12-18
* @Version: V1.0
*/
@Api(tags="doctor_register_hospital")
@RestController
@RequestMapping("/api/v1/doctorRegisterHospital")
@Slf4j
public class DoctorRegisterHospitalController extends JeecgController<DoctorRegisterHospital, IDoctorRegisterHospitalService> {
   @Autowired
   private IDoctorRegisterHospitalService doctorRegisterHospitalService;
   /**
    * 分页列表查询
    *
    * @param doctorRegisterHospital
    * @param req
    * @return
    */
   @AutoLog(value = "doctor_register_hospital-分页列表查询")
   @ApiOperation(value="doctor_register_hospital-分页列表查询", notes="doctor_register_hospital-分页列表查询")
   @GetMapping(value = "/list")
   public Result<?> queryPageList(DoctorRegisterHospital doctorRegisterHospital, HttpServletRequest req) {
       LambdaQueryWrapper query = new LambdaQueryWrapper(DoctorRegisterHospital.class);
       query.last(" order by FIELD(sort,0,1,2,3,4,5)");
       //（1）先查询所有信息
       List<DoctorRegisterHospital> list = doctorRegisterHospitalService.list(query);
       log.info("查询到的医院数据：{}",String.valueOf(list));
       return Result.ok(list);
   }


   /**
    * 通过id查询
    *
    * @param id
    * @return
    */
   @AutoLog(value = "doctor_register_hospital-通过id查询")
   @ApiOperation(value="doctor_register_hospital-通过id查询", notes="doctor_register_hospital-通过id查询")
   @GetMapping(value = "/queryById")
   public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
       DoctorRegisterHospital doctorRegisterHospital = doctorRegisterHospitalService.getById(id);
       if(doctorRegisterHospital==null) {
           return Result.error("未找到对应数据");
       }
       return Result.ok(doctorRegisterHospital);
   }


}
